//
//  WorkListCell.m
//  Patrol
//
//  Created by Lee on 13-2-28.
//  Copyright (c) 2013年 FSTI. All rights reserved.
//

#import "WorkListCell.h"
#define kdescLabelWidth 200.0f
#define kdescLabelHeight 20.0f
#define kDefaultCellHeight 44.0f
@implementation WorkListCell



- (void)setCellContent:(NSString * ) desc Number:(NSString *)numStr
{
    _decLabel.text = desc;
    _numberLabel.text = numStr;

    CGFloat actualHeight = [WorkListCell calcLabelHeightForString:desc];
    if (actualHeight <= kdescLabelHeight) {
        return ;
    }else{
        CGFloat diff  = actualHeight - kdescLabelHeight;
        [_decLabel.po_frameBuilder setHeight:actualHeight];
        [self.po_frameBuilder setHeight:(diff + CGRectGetHeight(self.frame)) ];
        [_numberLabel.po_frameBuilder centerVerticallyInSuperview];
    }
}

+ (CGFloat) calcLabelHeightForString:(NSString * )content
{
    UIFont * labelFont = [UIFont systemFontOfSize:17];
    static CGSize constrainedSize = {kdescLabelWidth, CGFLOAT_MAX};
    CGFloat height =  [content sizeWithFont:labelFont constrainedToSize:constrainedSize lineBreakMode:UILineBreakModeWordWrap].height;
    return height;
}

- (void)prepareForReuse
{
    [super prepareForReuse];
    [self.po_frameBuilder setHeight:kDefaultCellHeight];
}

@end
